package com.example.langchaindemo.base;


import com.example.langchaindemo.Const.APIConst;
import com.example.langchaindemo.config.Langchain4jProperties;
import com.example.langchaindemo.service.AiAssistant;
import dev.langchain4j.community.model.dashscope.QwenChatModel;
import dev.langchain4j.data.message.AiMessage;
import dev.langchain4j.data.message.SystemMessage;
import dev.langchain4j.data.message.UserMessage;
import dev.langchain4j.model.chat.ChatLanguageModel;
import io.github.cdimascio.dotenv.Dotenv;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 普通聊天
 */
@RequestMapping("/api")
@RestController
@RequiredArgsConstructor
public class ChatSample {
    final ChatLanguageModel model;

    final AiAssistant assistant;

    final Langchain4jProperties properties;

    @GetMapping("/lowlevel/chat")
    public String lowChat(@RequestParam("message") String message) {
        SystemMessage sys_message = SystemMessage.from("假如你是周杰伦，请用周杰伦的口吻和我对话");
        return model.chat(sys_message, UserMessage.from(message)).aiMessage().text();
    }

    @GetMapping("/highlevel/chat")
    public String highChat(@RequestParam("message") String message) {
        String answer = assistant.chat(message);
        return answer;
    }
}
